package com.mop.sg2.animate;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

public class BaseAnimation {

	private int[] imgIds = null;

	private Bitmap[] imgsBitmap = null;

	private Resources r = null;

	boolean isAnimationOn = false;

	Thread animationThread = null;

	public BaseAnimation(Resources r, int[] imgIds) throws Exception {
		this.imgIds = imgIds;
		if (imgIds == null || imgIds.length < 1) {
			throw new Exception();
		}
	}

	private void initAnimationSegment(Resources r) {
		imgsBitmap = new Bitmap[this.imgIds.length];
		for (int i = 0; i < this.imgIds.length; i++) {
			imgsBitmap[i] = BitmapFactory.decodeResource(r, imgIds[i]);
		}
	}

	// 方法：开始换帧动画
	public void startAnimation(Canvas canvas, int times) {
		animationThread = new Thread(new Runnable() {
			@Override
			public void run() {
				BaseAnimation.this.isAnimationOn = true;
				int index = 0;
				int total = imgsBitmap.length;
				while (BaseAnimation.this.isAnimationOn) {
					index++;
					index = index % total;
//					canvas.
				}
			}
		});
	}

	// 方法：暂停动画
	public void pauseAnimation() {

	}

	public void run() {

	}

}
